<template lang="html">
  <article id="views-court">
    <CourtItem
      v-for="(item, index) in courtList"
      :courtDetail="item"
      :key="item.storeId"
    />
  </article>
</template>

<script>
import superagent from 'superagent'
import utils from '@/lib/utils'
import authMiddleware from '@/lib/auth-middleware'
export default {
  name: 'PageCourt',
  components: {
    CourtItem: require('@/components/court_item')
  },
  data(){
    return {
      courtList: []
    }
  },
  created(){
    this.getCourtList()
    .then(data => {
      this.courtList = data
    })
  },
  methods: {
    getCourtList(){
      return new Promise((resolve, reject) => {
        superagent.post('/api/store/index')
          .use(authMiddleware())
          .end((err, res) => {
            if(res.ok){
              resolve(res.body.data.stores)
            } else {
              reject(new Error('getCourtList error'))
            }
          })
      })
    }
  }
}
</script>

<style lang="scss" scoped>
@import "../css/config";
#views-court{
  width: 100%;
  min-height: 100%;
  background-color: $common-bg;
  overflow-y: scroll;
  box-sizing: border-box;
  padding: 37px 25px $tablist-height 25px;
}
</style>
